package com.juzipi.demo.controller;


import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {



    @PreAuthorize("hasAnyRole('ADMIN')")
    @GetMapping("admin")
    public String hello(){

        return "admin权限才可以";
    }

    @GetMapping("test")
    public String test(){

        return "都可以访问";
    }


    @PreAuthorize("hasAnyRole('USER')")
    @GetMapping("user")
    public String user(){

        return "user权限admin权限都可以";
    }


}
